package com.jyhs.maven.proxy.dynamic;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class CglibProxyInterceptor implements MethodInterceptor{
    @Override
    public Object intercept(Object o, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        long startTime = System.currentTimeMillis();
        Object result = methodProxy.invokeSuper(o, args);
        long endTime = System.currentTimeMillis();
        System.out.println("CGLIB多态代理class:"+o.getClass().getName()+",Method: " + method.getName() + " execution time: " + (endTime - startTime) + "ms");
        return result;
    }
}
